class Solution:
    def getLucky(self, s: str, k: int) -> int:
        v = "".join([str(ord(ch) - 96) for ch in s])

        for _ in range(k):
            v = str(sum(int(ch) for ch in v))

        return int(v)


if __name__ == "__main__":
    print(Solution().getLucky(s="iiii", k=1))  # 36
    print(Solution().getLucky(s="leetcode", k=2))  # 6
